const { list, tabs } = require('./src/mock')

let data = [...list];
tabs.forEach(v => {
  data = [...data, ...v.children]
})


const bodyParser = require('body-parser')
module.exports = {
  devServer: {
    before(app) {
      app.use(bodyParser.json())
      app.get('/api/list', (req, res) => {
          res.send({
            code: 200,
            data: list
          })
      })


      app.get('/api/tabs', (req, res) => {
        res.send({
          code: 200,
          data: tabs
        })
    })


      app.post('/api/detail', (req, res) => {
        const { id } = req.body
        const item = data.find(item => item.id === id)
        res.send({
          code: 200,
          data: item
        })
      })
    }
  }
}